import { request } from '../network/request.js'
import router from '../router/index'
export default ({
    namespaced: true,
    state: {
    },
    mutations: {
    },
    actions: {
        async login(context, {
            name, password, type, ice
        }) {
            // console.log( name, password, type, ice);
            const msg = await request({
                url: '/user/login',
                method: 'post',
                data: {
                    name, password, type, ice
                }
            });
            console.log(99999,msg);
            if (msg.type == '商家' && msg.success == true) {
                //console.log(msg);
                
                localStorage.type='商家'
                router.push('/system');
            } else if (msg.type == '超管') { 
                localStorage.type='超管'
                router.push('/system');
               
            } else{
               console.log(555)
            }
           
    },

    async register(context, { name, password, type, ice }) {
        const msg = await request({
            url: '/user/register',
            method: 'post',
            data: {
                name, password, type, ice
            }
        });

        return msg
    }
}, modules: {

}
})